//
//  ViewController.m
//  UI09_UITabBarController
//
//  Created by Scott on 16/3/21.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "VCOf2ndFirstItem.h"

@interface ViewController ()

@property (nonatomic, retain) UIButton *button;

@property (nonatomic, retain) UIButton *buttonOfNext;
@end

@implementation ViewController

- (void)dealloc {
    [_button release];
    [_buttonOfNext release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    

    self.view.backgroundColor = [UIColor redColor];
    
    self.navigationItem.title = @"首页";
    
    [self createButton];
    
}


#pragma mark - 
- (void)createButton {
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    
    self.button.frame = CGRectMake(50, 80, self.view.frame.size.width - 100, 40);
    
    [self.button setTitle:@"已读" forState:UIControlStateNormal];
    
    [self.view addSubview:self.button];
    
    self.button.backgroundColor = [UIColor yellowColor];
    
    [self.button addTarget:self action:@selector(handleRead:) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.buttonOfNext = [UIButton buttonWithType:UIButtonTypeSystem];
    
    self.buttonOfNext.frame = CGRectMake(50, 150, self.view.frame.size.width - 100, 40);
    
    [self.buttonOfNext setTitle:@"下一页" forState:UIControlStateNormal];
    
    [self.view addSubview:self.buttonOfNext];
    
    self.buttonOfNext.backgroundColor = [UIColor yellowColor];
    
    [self.buttonOfNext addTarget:self action:@selector(handleNext:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

/** 角标清除. */
- (void)handleRead:(UIButton *)button {
    
    // 找到相应的tabBarItem对象.
    self.navigationController.tabBarItem.badgeValue = nil;
}

- (void)handleNext:(UIButton *)button {
    
    VCOf2ndFirstItem *second = [[VCOf2ndFirstItem alloc] init];
    
    [self.navigationController pushViewController:second animated:YES];
    
    [second release];
    
}

#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
